/*
 * Resource.cpp
 *
 *  Created on: 18.2.2013
 *      Author: Travis
 */

#include "Resource.h"

namespace GameLogic
{
Resource *resource;

Resource::Resource(int _wood, int gold)
{
	wood = _wood;
	this->gold = gold;
}

void Resource::bindClass(LuaScript::LuaScript * lScript)
{
	lua_State * luaState = lScript->getLuaState();
	luabind::object * table = lScript->getTable();

	luabind::module(luaState)[luabind::class_ < Resource
			> ("Resource").def(luabind::constructor<int, int>()).def("getWood",
					&Resource::getWood).def("getGold", &Resource::getGold).def("DecGold",
					&Resource::DecGold).def("DecWood", &Resource::DecWood)];

	// push this object reference to lua script
	table[0]["resource"] = this;

}

Resource::~Resource()
{
}

void Resource::DecWood(int val)
{
	wood -= val;
}

void Resource::DecGold(int val)
{
	gold -= val;
}

void InitResource(int Wood, int Gold)
{
	resource = new Resource(Wood, Gold);
}

int Resource::getWood() const
{
	return wood;
}

void Resource::setWood(int wood)
{
	this->wood = wood;
}

int Resource::getGold() const
{
	return gold;
}

void Resource::setGold(int gold)
{
	this->gold = gold;
}

} /* namespace gameLogic */
